//random horde by Spam_One, using celery cly_z_horde.sqf - By Spam_One --------------------------------------
// check every 5 minutes ------------------------------------------------------------------------------------
// 10% of random horde spawn on player ----------------------------------------------------------------------
// simply as that -------------------------------------------------------------------------------------------
if (!isServer) exitWith {};

private ["_proba","_PosPlayer","_randomNum", "_victim", "_sleepTime"];
waitUntil {sleep 30; diag_log "RandomHwithCLY wait 30 sec"; count playableUnits > 0};


//why i can't do that !!!!!!!!!!! 
//_sleepTime = 120 + (1200 - (count playableUnits * 30)); 
_sleepTime = count playableUnits;
_sleepTime = 30 * _sleepTime;
_sleepTime = 1200 - _sleepTime;
_sleepTime = 120 + _sleepTime;

sleep _sleepTime;

_victim = playableUnits select (floor random count playableUnits);

//launch the horde in other thread
[] spawn {
	waitUntil {sleep 30; vehicle player == player}; //we wait that player go out from vehicle
	sleep 30;
	
	_randomNum = (10 + (floor random 25)); // allow randomness for zombies in hordes
	
	_position = [_victim, 50, 50 , 75] call WF_FNCT_getRandomSafePos;
					
	trigger = createTrigger ["EmptyDetector", _position];
	trigger setTriggerArea [10, 10, 0, false];
	
	[trigger, _randomNum, CLY_hordetrigger, "normal", _victim] execVM "WEFRAG\z_horde.sqf";
};

[] execVM "WEFRAG\RandomHwithCLY.sqf";
	
// End ------------------------------------------------------------------------------------------------------